package 结构型模型.组合模式;

import java.util.ArrayList;
import java.util.List;

public interface AbstractFile {
    void kill();
}
class ImageFile implements AbstractFile {

    private String name;

    public ImageFile(String name) {
        this.name = name;
    }

    @Override
    public void kill() {
        System.out.println("查杀--"+name+"...文件");
    }
}

class FloderFile implements AbstractFile{
    private String name;
    private List<AbstractFile> list=new ArrayList<>();

    public FloderFile(String name) {
        this.name = name;
    }

    public void   add(AbstractFile a){
          list.add(a);
      }
      public void   remove(AbstractFile a){
          list.remove(a);
      }
      AbstractFile get(int index){
         return list.get(index);
      }


    @Override
    public void kill() {
        System.out.println("查杀--"+name+"...文件夹");
        for (AbstractFile file : list) {
            file.kill();
        }
    }
}